<?php
/**
 * Created by PhpStorm.
 * User: wuchunyin
 * Date: 2019/1/11
 * Time: 15:57
 */

namespace app\index\report;

use app\index\service\ExcelService;
use think\Db;

class BookForGGJ {

    public static function getData(){
        $field = ["LAND_NAME","LAND_NO","ASSET_TYPE_ID","D.cname2010 ASSET_TYPE_NAME"
            ,"GETTYPE_ID","to_char(GET_DATE,'yyyy-mm-dd') GET_DATE","L.PURCHASE_ID","PROPERTYRIGHT_ID"
            ,"dp.POWERTYPE","OWNER_CERT","OWNER_CERT_NO","LAND_AREA","LAND_FEE","FINANCE_GET_FEE"
            ,"BUSINESS_GET_FEE","BUSINESS_BUDGET_GET_FEE","OTHER_FEE","LAND_SIZE","ds.STATUS"
            ,"SELF_SIZE","BORROW_SIZE","RENTAL_SIZE","INVESTMENT_SIZE","GUARANTEE_SIZE","ELSE_SIZE"
            ,"'' as USE_TYPE","'' as NET_VALUE","REMARK"];
        $list = Db::table("ASSET_LAND L")
            ->field($field)
            ->leftJoin("ASSET_DICT_PURCHASE d1","d1.PURCHASE_ID=l.PURCHASE_ID")
            ->leftJoin("asset_dict_type94to2010 d","d.ccode94=l.asset_type_id")
            ->leftJoin("asset_dict_powertype dp",'dp.powertype_id=l.powertype_id')
            ->leftJoin('asset_dict_status ds','ds.status_id=l.status_id')
            ->select();
        return $list;
    }

    public static function exportData($data){
        $fieldList = [
            ['title'=>'资产名称','field'=>'LAND_NAME'],
            ['title'=>'资产编号','field'=>'LAND_NO'],
            ['title'=>'资产分类代码','field'=>'ASSET_TYPE_ID'],
            ['title'=>'资产分类名称','field'=>'ASSET_TYPE_NAME'],
            ['title'=>'取得方式','field'=>'GETTYPE_ID'],
            ['title'=>'取得日期','field'=>'GET_DATE'],
            ['title'=>'采购组织形式','field'=>'PURCHASE_ID'],
            ['title'=>'产权形式','field'=>'PROPERTYRIGHT_ID'],
            ['title'=>'权属性质','field'=>'POWERTYPE'],
            ['title'=>'权属证明','field'=>'OWNER_CERT'],
            ['title'=>'权属证号','field'=>'OWNER_CERT_NO'],
            ['title'=>'坐落位置','field'=>'LAND_AREA'],
            ['title'=>'原值','field'=>'LAND_FEE'],
            ['title'=>'财政拨款','field'=>'FINANCE_GET_FEE'],
            ['title'=>'事业收入','field'=>'BUSINESS_GET_FEE'],
            ['title'=>'其中：预算外资金','field'=>'BUSINESS_BUDGET_GET_FEE'],
            ['title'=>'其他资金','field'=>'OTHER_FEE'],
            ['title'=>'土地面积（㎡）','field'=>'LAND_SIZE'],
            ['title'=>'使用状况','field'=>'STATUS'],
            ['title'=>'自用面积','field'=>'SELF_SIZE'],
            ['title'=>'出借面积','field'=>'BORROW_SIZE'],
            ['title'=>'出租面积','field'=>'RENTAL_SIZE'],
            ['title'=>'对外投资面积','field'=>'INVESTMENT_SIZE'],
            ['title'=>'担保面积','field'=>'GUARANTEE_SIZE'],
            ['title'=>'其他面积','field'=>'ELSE_SIZE'],
            ['title'=>'用途分类','field'=>'USE_TYPE'],
            ['title'=>'净值','field'=>'NET_VALUE'],
            ['title'=>'备注','field'=>'REMARK']
        ];

        $excel = new ExcelService();
        $excel->exportExcel($data,"国管局土地",$fieldList);
    }


}
